<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    import="beans.UserBean, beans.MessageBean, beans.EventBean, java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>drop.in - <% UserBean visitingUser = (UserBean)session.getAttribute("visitingUser"); out.print(visitingUser.getName()); %></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      #sexyline { 
          margin: 25px 0;
          height: 1px;
          background: #eeeee;
          background: -webkit-gradient(linear, 0 0, 100% 0, from(white), to(white), color-stop(50%, grey));
      }​
    </style>
    <link href="css/bootstrap-responsive.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="ico/favicon.ico">
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="ico/apple-touch-icon-144-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="ico/apple-touch-icon-114-precomposed.png">
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="ico/apple-touch-icon-72-precomposed.png">
    <link rel="apple-touch-icon-precomposed" href="ico/apple-touch-icon-57-precomposed.png">
  </head>

  <body>

    <div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="#">drop.in</a>
          <div class="nav-collapse">
            <ul class="nav">
              <li class="active"><a href="#">Home</a></li>
              <li><a href="#about">About</a></li>
              <li><a href="#contact">Contact</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

    <div class="container">

      <!-- Main hero unit for a primary marketing message or call to action -->
      <div class="hero-unit" style="padding: 10px 10px 10px 10px;">
        <div>
        <div style="float: right; text-align: right;">
        <h1></h1>
        </div>
        <h2><% out.print(visitingUser.getName()); %></h2>
        <p><% Boolean usergender = visitingUser.getGenderMale();
					if (usergender) { out.print("Male"); } else { out.print("Female"); }; %>, <% out.print(visitingUser.getAgeYears()); %> years old | Lives in <% out.print(visitingUser.getCity()); %>, <% out.print(visitingUser.getCountry()); %></p>
        </div>
      </div>
      <div class="row">
        <div class="span4">
   		<ul class="thumbnails">
   		  <li class="span4">
   		    <div class="thumbnail">
   		      <img src="<% out.print(visitingUser.getPhotoURL()); %>" alt="" width="290" height="290">
   		    </div>
   		    <div style="padding-left: 5px; padding-top: 10px;">
   		    <h4>Stats:</h4><br />
   		    <p>Average Host Rating: <% out.print(visitingUser.getHostRatingAvg()); %></p>
   		    <p>Average Guest Rating: <% out.print(visitingUser.getGuestRatingAvg()); %></p>
   		    <p># Events Hosted: <% out.print(visitingUser.getTotalHosted()); %></p>   		    
   		    <p># Events Attended: <% out.print(visitingUser.getTotalAttended()); %></p>
   		    </div>
   		  </li>
   		</ul>
        </div>
        <div class="span8">
            <h3>Recent Messages and Comments:</h3>
              <% 	ArrayList<MessageBean> recentMessages = (ArrayList<MessageBean>)session.getAttribute("recentvisitingmessages");
            	if (recentMessages.isEmpty()) {
            		out.print("<blockquote style='text-align: center; height: 100px; font-size: 18px; font-style: italic; padding-top: 70px;'>There are no messages to display!</blockquote>");
            	} else {
            		for (int i=0; i<recentMessages.size(); i++) {
            			out.print("<blockquote>"+recentMessages.get(i).getBody()+"<small>Sent by <a href='http://localhost:8080/dropin/VisitServlet?visitid=" + recentMessages.get(i).getSender() + "'>"); out.print(recentMessages.get(i).getSenderName()); out.print("</a> on "); String msgdate= (recentMessages.get(i).getStamp().toString()); out.print(msgdate.substring(0, 16) + "</small></blockquote>");
            		}
            	}
            %>
            <a href="http://localhost:8080/dropin/ReplyServlet?reply=1&to=<% out.print(visitingUser.getEmail()); %>" class="btn" style="width: 97%;">Send a message to <% out.print(visitingUser.getName()); %></a>
            <div id="sexyline"></div>
            <h3>Recent Activities:</h3>
              <% 	java.util.Date now = new java.util.Date();
              	ArrayList<EventBean> events = (ArrayList<EventBean>)session.getAttribute("usersvisitingevent");
            	if (events.isEmpty())
            		out.print("<blockquote style='text-align: center; height: 100px; font-size: 18px; font-style: italic; padding-top: 70px;'>You haven't done anything yet!<br />Why don't you <a href='http://localhost:8080/dropin/searchevent.jsp'>search for something to do</a>?</blockquote>");
            	else {
            		int o = 10; if (events.size() < 10) o = events.size();
            	for (int i=0; i < o; i++) {
            		String start = events.get(i).getStartTimeStamp().toString();
        			start = start.substring(0, 19);
        			start = start.replace("-", "");
        			start = start.replace(":", "");
        			start = start.replace(" ", "");
            		if (events.get(i).getHost().equals(visitingUser.getEmail()))
            			if (now.before(events.get(i).getStartTimeStamp()))
            				out.print("<p>" + visitingUser.getName() + " will host the event <a href='http://localhost:8080/dropin/EventServlet?host=" + events.get(i).getHost() + "&start=" + start + "'>" + events.get(i).getName() + "</a><span style='color: gray'> (" + events.get(i).getStartTimeStamp().toString().substring(0, 16) + ")</span></p>");
            			else
            				out.print("<p>" + visitingUser.getName() + " hosted the event <a href='http://localhost:8080/dropin/EventServlet?host=" + events.get(i).getHost() + "&start=" + start + "'>" + events.get(i).getName() + "</a><span style='color: gray'> (" + events.get(i).getStartTimeStamp().toString().substring(0, 16) + ")</span></p>");
            		else
            			if (now.before(events.get(i).getStartTimeStamp()))
            				out.print("<p>" + visitingUser.getName() + " will attend the event <a href='http://localhost:8080/dropin/EventServlet?host=" + events.get(i).getHost() + "&start=" + start + "'>" + events.get(i).getName() + "</a><span style='color: gray'> (" + events.get(i).getStartTimeStamp().toString().substring(0, 16) + ")</span></p>");
            			else
            				out.print("<p>" + visitingUser.getName() + " attended the event <a href='http://localhost:8080/dropin/EventServlet?host=" + events.get(i).getHost() + "&start=" + start + "'>" + events.get(i).getName() + "</a><span style='color: gray'> (" + events.get(i).getStartTimeStamp().toString().substring(0, 16) + ")</span></p>");
            	} }
            	out.print("<a href='http://localhost:8080/dropin/MyEventServlet?id=" + visitingUser.getEmail() + "###' class='btn' style='width: 97%;''>See all your activities</a>");
            %>
	  </div>
	  </div>
	  </div>
      <footer>
        <p style="text-align: center; margin-top: 50px; color: grey;">&copy; PiP 2012</p>
      </footer>

    </div> <!-- /container -->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script src="js/bootstrap.js"></script>
    <script src="js/bootstrap-alert.js"></script>
    <script src="js/bootstrap-modal.js"></script>
    <script src="js/bootstrap-dropdown.js"></script>
    <script src="js/bootstrap-scrollspy.js"></script>
    <script src="js/bootstrap-tab.js"></script>
    <script src="js/bootstrap-tooltip.js"></script>
    <script src="js/bootstrap-popover.js"></script>
    <script src="js/bootstrap-button.js"></script>
    <script src="js/bootstrap-collapse.js"></script>
    <script src="js/bootstrap-carousel.js"></script>
    <script src="js/bootstrap-typeahead.js"></script>

  </body>
</html>
